package com.leyou.trade.web;

import com.leyou.trade.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * @author 虎哥
 */
@RestController
@RequestMapping("/pay")
public class PayController {

    @Autowired
    private OrderService orderService;

    /**
     * 获取支付链接
     *
     * @param orderId 订单id
     * @return 支付链接
     */
    @GetMapping("/url/{id}")
    public ResponseEntity<String> getPayUrl(@PathVariable("id") Long orderId) {
        return ResponseEntity.ok(orderService.getPayUrl(orderId));
    }

    /**
     * 微信支付回调
     * @return 回调回执
     */
    @PostMapping("/wx/notify")
    public ResponseEntity<String> handleWxNotify() {
        return ResponseEntity.ok("hello");
    }
}
